Load all required libraries.
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.3 v dplyr 1.0.7
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 2.0.0 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(broom)
Read in raw data from RDS.
raw_data <- readRDS("./year2.RDS")
Make a few small modifications to names and data for visualizations.
final_data <- raw_data %>% mutate(log_copy_per_L = log10(mean_copy_num_L)) %>%
rename(Facility = wrf) %>%
mutate(Facility = recode(Facility,
"NO" = "WRF A",
"MI" = "WRF B",
"CC" = "WRF C"))
Seperate the data by gene target to ease layering in the final plot
#make three data layers
only_positives <<- subset(final_data, (!is.na(final_data$Facility)))
only_n1 <- subset(only_positives, target == "N1")
only_n2 <- subset(only_positives, target == "N2")
only_background <<-final_data %>%
select(c(date, cases_cum_clarke, new_cases_clarke, X7_day_ave_clarke)) %>%
group_by(date) %>% summarise_if(is.numeric, mean)
#specify fun colors
background_color <- "#7570B3"
seven_day_ave_color <- "#E6AB02"
marker_colors <- c("N1" = '#1B9E77',"N2" ='#D95F02')
#remove facilty C for now
#only_n1 <- only_n1[!(only_n1$Facility == "WRF C"),]
#only_n2 <- only_n2[!(only_n2$Facility == "WRF C"),]
only_n1 <- only_n1[!(only_n1$Facility == "WRF A" & only_n1$date == "2020-11-02"), ]
only_n2 <- only_n2[!(only_n2$Facility == "WRF A" & only_n2$date == "2020-11-02"), ]
Build the main plot
#first layer is the background epidemic curve
p1 <- only_background %>%
plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~new_cases_clarke,
type = "bar",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Daily Cases: ', new_cases_clarke),
alpha = 0.5,
name = "Daily Reported Cases",
color = background_color,
colors = background_color,
showlegend = FALSE) %>%
layout(yaxis = list(title = "Clarke County Daily Cases", showline=TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#renders the main plot layer two as seven day moving average
p1 <- p1 %>% plotly::add_trace(x = ~date, y = ~X7_day_ave_clarke,
type = "scatter",
mode = "lines",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Seven-Day Moving Average: ', X7_day_ave_clarke),
name = "Seven Day Moving Average Athens",
line = list(color = seven_day_ave_color),
showlegend = FALSE)
#renders the main plot layer three as positive target hits
p2 <- plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n1,
symbol = ~Facility,
marker = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n2,
symbol = ~Facility,
marker = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(yaxis = list(title = "SARS CoV-2 Copies/L",
showline = TRUE,
type = "log",
dtick = 1,
automargin = TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#adds the limit of detection dashed line
p2 <- p2 %>% plotly::add_segments(x = as.Date("2021-06-30"),
xend = ~max(date + 10),
y = 3571.429, yend = 3571.429,
opacity = 0.35,
line = list(color = "black", dash = "dash")) %>%
layout(annotations = list(x = as.Date("2021-06-30"), y = 3.8, xref = "x", yref = "y",
text = "Limit of Detection", showarrow = FALSE))
p1
p2
Combine the two main plot pieces as a subplot
#seperate n1 and n2 frames by site
#n1
wrf_a_only_n1 <- subset(only_n1, Facility == "WRF A")
wrf_b_only_n1 <- subset(only_n1, Facility == "WRF B")
wrf_c_only_n1 <- subset(only_n1, Facility == "WRF C")
#n2
wrf_a_only_n2 <- subset(only_n2, Facility == "WRF A")
wrf_b_only_n2 <- subset(only_n2, Facility == "WRF B")
wrf_c_only_n2 <- subset(only_n2, Facility == "WRF C")
#rejoin the old data frames then seperate in to averages for each plant.
wrfa_both <- full_join(wrf_a_only_n1, wrf_a_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
wrfb_both <- full_join(wrf_b_only_n1, wrf_b_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
wrfc_both <- full_join(wrf_c_only_n1, wrf_c_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
#get max date
maxdate <- max(wrfa_both$date)
mindate <- min(wrfa_both$date)
Build loess smoothing figures figures
This makes the individual plots
#**************************************WRF A PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_botha <- ggplot(wrfa_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_botha<<-..y..), method = "loess", color = '#1B9E77',
span = 0.3, n = 225)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_botha
## `geom_smooth()` using formula 'y ~ x'
fit_botha
## [1] 11.53477 11.57286 11.61065 11.64814 11.68533 11.72221 11.75877 11.79498
## [9] 11.83083 11.86634 11.90152 11.93641 11.97103 12.00538 12.03950 12.07337
## [17] 12.10695 12.14024 12.17324 12.20595 12.23837 12.27050 12.30245 12.33428
## [25] 12.36589 12.39722 12.42817 12.45868 12.48865 12.51754 12.54513 12.57178
## [33] 12.59789 12.62383 12.64998 12.67672 12.70441 12.73286 12.76162 12.79026
## [41] 12.81834 12.84542 12.87106 12.89797 12.92803 12.95955 12.99084 13.02023
## [49] 13.04601 13.06651 13.08504 13.10519 13.12565 13.14513 13.16235 13.17601
## [57] 13.18482 13.19076 13.19626 13.20064 13.20325 13.20343 13.20052 13.19385
## [65] 13.18161 13.16340 13.14075 13.11518 13.08820 13.06134 13.03611 13.00819
## [73] 12.97372 12.93500 12.89429 12.85385 12.81596 12.78289 12.75058 12.71445
## [81] 12.67604 12.63687 12.59849 12.56241 12.53017 12.49715 12.45935 12.41919
## [89] 12.37909 12.34147 12.30878 12.28342 12.26433 12.24836 12.23483 12.22306
## [97] 12.21238 12.20209 12.19152 12.18238 12.17650 12.17336 12.17245 12.17325
## [105] 12.17524 12.17790 12.18072 12.18318 12.18477 12.18496 12.18325 12.17945
## [113] 12.17426 12.16844 12.16276 12.15798 12.15487 12.15420 12.15492 12.15561
## [121] 12.15647 12.15770 12.15951 12.16210 12.16568 12.17003 12.17479 12.17994
## [129] 12.18544 12.19128 12.19741 12.20381 12.21371 12.22892 12.24733 12.26681
## [137] 12.28524 12.30049 12.31044 12.31819 12.32760 12.33773 12.34764 12.35639
## [145] 12.36305 12.36667 12.36475 12.35661 12.34406 12.32891 12.31295 12.29799
## [153] 12.28583 12.27828 12.27715 12.27873 12.27857 12.27732 12.27566 12.27424
## [161] 12.27371 12.27475 12.27802 12.28417 12.29387 12.30778 12.32656 12.35343
## [169] 12.38912 12.43058 12.47473 12.51850 12.55883 12.59265 12.62743 12.67152
## [177] 12.72312 12.78047 12.84179 12.90529 12.96920 13.03174 13.09113 13.14560
## [185] 13.19336 13.23264 13.26167 13.27865 13.28586 13.28743 13.28438 13.27774
## [193] 13.26854 13.25780 13.24654 13.23129 13.20912 13.18183 13.15122 13.11911
## [201] 13.08730 13.05760 13.02757 12.99395 12.95728 12.91808 12.87691 12.83429
## [209] 12.79078 12.74548 12.69736 12.64675 12.59393 12.53922 12.48294 12.42538
## [217] 12.36652 12.30612 12.24410 12.18041 12.11498 12.04777 11.97871 11.90773
## [225] 11.83479
#assign fits to a vector
both_trenda <- fit_botha
#extract y min and max for each
limits_botha <- ggplot_build(extract_botha)$data
## `geom_smooth()` using formula 'y ~ x'
limits_botha <- as.data.frame(limits_botha)
both_ymina <- limits_botha$ymin
both_ymaxa <- limits_botha$ymax
#reassign dataframes (just to be safe)
work_botha <- wrfa_both
#fill in missing dates to smooth fits
work_botha <- work_botha %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_botha <- work_botha$date
#create a new smooth dataframe to layer
smooth_frame_botha <- data.frame(date_vec_botha, both_trenda, both_ymina, both_ymaxa)
#WRF A
#plot smooth frames
p_wrf_a <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_botha, y = ~both_trenda,
data = smooth_frame_botha,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha,
'</br> Median Log Copies: ', round(both_trenda, digits = 2)),
line = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_botha, ymin = ~both_ymina, ymax = ~both_ymaxa,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxa, digits = 2),
'</br> Min Log Copies: ', round(both_ymina, digits = 2)),
name = "",
fillcolor = '#1B9E77',
line = list(color = '#1B9E77')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF A") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfa_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#1B9E77', size = 6, opacity = 0.65))
p_wrf_a
save(p_wrf_a, file = "./site_objects/wrf_a_year2.rda")
#**************************************WRF B PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothb <- ggplot(wrfb_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothb<<-..y..), method = "loess", color = '#D95F02',
span = 0.3, n = 225)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothb
## `geom_smooth()` using formula 'y ~ x'
fit_bothb
## [1] 10.68837 10.78481 10.87913 10.97137 11.06156 11.14974 11.23595 11.32019
## [9] 11.40243 11.48262 11.56074 11.63676 11.71064 11.78234 11.85185 11.91910
## [17] 11.98412 12.04695 12.10761 12.16617 12.22265 12.27710 12.32912 12.37846
## [25] 12.42536 12.47009 12.51287 12.55398 12.59364 12.63122 12.66613 12.69875
## [33] 12.72943 12.75856 12.78650 12.81361 12.83777 12.85729 12.87329 12.88686
## [41] 12.89909 12.91109 12.92393 12.93535 12.94299 12.94792 12.95118 12.95382
## [49] 12.95688 12.96141 12.96774 12.97503 12.98257 12.98966 12.99561 12.99971
## [57] 13.00126 12.99932 12.99414 12.98682 12.97842 12.97002 12.96272 12.95759
## [65] 12.95200 12.94337 12.93281 12.92145 12.91040 12.90079 12.89373 12.89005
## [73] 12.88901 12.88938 12.88990 12.88935 12.88649 12.88007 12.87334 12.86937
## [81] 12.86673 12.86396 12.85960 12.85220 12.84031 12.82411 12.80522 12.78440
## [89] 12.76238 12.73991 12.71775 12.69662 12.67220 12.64128 12.60630 12.56973
## [97] 12.53400 12.50157 12.47489 12.45294 12.43274 12.41381 12.39567 12.37784
## [105] 12.35984 12.34119 12.32141 12.30002 12.27654 12.25049 12.22138 12.18325
## [113] 12.13379 12.07801 12.02094 11.96762 11.92306 11.89230 11.86377 11.82583
## [121] 11.78341 11.74140 11.70473 11.67829 11.66702 11.66723 11.67157 11.67939
## [129] 11.69007 11.70296 11.71743 11.73284 11.75711 11.79528 11.84243 11.89362
## [137] 11.94391 11.98837 12.02207 12.05655 12.10339 12.15772 12.21466 12.26934
## [145] 12.31688 12.35242 12.38050 12.40871 12.43675 12.46431 12.49107 12.51672
## [153] 12.54095 12.56345 12.58391 12.60004 12.61053 12.61652 12.61914 12.61953
## [161] 12.61883 12.61816 12.61868 12.62150 12.62778 12.63864 12.65523 12.68037
## [169] 12.71402 12.75303 12.79424 12.83448 12.87059 12.89941 12.92550 12.95503
## [177] 12.98725 13.02141 13.05676 13.09256 13.12806 13.16251 13.19517 13.22528
## [185] 13.25209 13.27487 13.29286 13.30531 13.31364 13.31981 13.32393 13.32610
## [193] 13.32641 13.32499 13.32191 13.31694 13.30985 13.30078 13.28986 13.27725
## [201] 13.26307 13.24748 13.23011 13.21063 13.18922 13.16604 13.14125 13.11503
## [209] 13.08755 13.05860 13.02790 12.99549 12.96142 12.92574 12.88849 12.84972
## [217] 12.80941 12.76752 12.72404 12.67895 12.63224 12.58391 12.53393 12.48230
## [225] 12.42901
#assign fits to a vector
both_trendb <- fit_bothb
#extract y min and max for each
limits_bothb <- ggplot_build(extract_bothb)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothb <- as.data.frame(limits_bothb)
both_yminb <- limits_bothb$ymin
both_ymaxb <- limits_bothb$ymax
#reassign dataframes (just to be safe)
work_bothb <- wrfb_both
#fill in missing dates to smooth fits
work_bothb <- work_bothb %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothb <- work_bothb$date
#create a new smooth dataframe to layer
smooth_frame_bothb <- data.frame(date_vec_bothb, both_trendb, both_yminb, both_ymaxb)
#WRF B
#plot smooth frames
p_wrf_b <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothb, y = ~both_trendb,
data = smooth_frame_bothb,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb,
'</br> Median Log Copies: ', round(both_trendb, digits = 2)),
line = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothb, ymin = ~both_yminb, ymax = ~both_ymaxb,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxb, digits = 2),
'</br> Min Log Copies: ', round(both_yminb, digits = 2)),
name = "",
fillcolor = '#D95F02',
line = list(color = '#D95F02')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF B") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfb_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#D95F02', size = 6, opacity = 0.65))
p_wrf_b
save(p_wrf_b, file = "./site_objects/wrf_b_year2.rda")
#**************************************WRF C PLOT********************************************** #add trendlines #extract data from geom_smooth # *********************************span 0.6*********************************** #*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothc <- ggplot(wrfc_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothc<<-..y..), method = "loess", color = '#E7298A',
span = 0.3, n = 225)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothc
## `geom_smooth()` using formula 'y ~ x'
fit_bothc
## [1] 10.76694 10.84181 10.91506 10.98650 11.05594 11.12321 11.18810 11.25087
## [9] 11.31188 11.37110 11.42855 11.48421 11.53807 11.59013 11.64038 11.68841
## [17] 11.73402 11.77751 11.81914 11.85921 11.89801 11.93582 11.97065 12.00112
## [25] 12.02835 12.05349 12.07767 12.10203 12.12772 12.15313 12.17632 12.19796
## [33] 12.21866 12.23909 12.25988 12.28167 12.30310 12.32275 12.34117 12.35888
## [41] 12.37645 12.39442 12.41334 12.43496 12.45969 12.48607 12.51260 12.53782
## [49] 12.56023 12.57837 12.59307 12.60625 12.61799 12.62839 12.63754 12.64555
## [57] 12.65251 12.66033 12.67003 12.68036 12.69008 12.69793 12.70267 12.70305
## [65] 12.69905 12.69195 12.68246 12.67129 12.65913 12.64671 12.63471 12.61920
## [73] 12.59727 12.57123 12.54338 12.51603 12.49147 12.47201 12.45685 12.44314
## [81] 12.43007 12.41687 12.40272 12.38685 12.36845 12.34684 12.32257 12.29668
## [89] 12.27023 12.24426 12.21982 12.19795 12.17533 12.14912 12.12111 12.09309
## [97] 12.06684 12.04415 12.02682 12.01357 12.00186 11.99157 11.98256 11.97472
## [105] 11.96790 11.96199 11.95685 11.95236 11.94838 11.94479 11.94146 11.94177
## [113] 11.94767 11.95694 11.96733 11.97660 11.98253 11.98287 11.98172 11.98376
## [121] 11.98764 11.99198 11.99544 11.99665 11.99424 11.98580 11.97145 11.95364
## [129] 11.93485 11.91753 11.90415 11.89717 11.89483 11.89339 11.89235 11.89121
## [137] 11.88947 11.88663 11.88218 11.87579 11.86791 11.85924 11.85048 11.84231
## [145] 11.83544 11.83055 11.82496 11.81632 11.80585 11.79476 11.78427 11.77559
## [153] 11.76994 11.76854 11.77261 11.77986 11.78740 11.79547 11.80432 11.81420
## [161] 11.82536 11.83805 11.85251 11.86901 11.88779 11.90910 11.93318 11.96347
## [169] 12.00147 12.04456 12.09015 12.13561 12.17833 12.21571 12.25377 12.29933
## [177] 12.35101 12.40744 12.46722 12.52897 12.59131 12.65285 12.71221 12.76800
## [185] 12.81884 12.86334 12.90013 12.92781 12.94901 12.96736 12.98294 12.99585
## [193] 13.00618 13.01403 13.01949 13.02343 13.02623 13.02725 13.02584 13.02137
## [201] 13.01320 13.00067 12.98447 12.96567 12.94420 12.92002 12.89306 12.86327
## [209] 12.83059 12.79516 12.75711 12.71638 12.67292 12.62664 12.57749 12.52540
## [217] 12.47038 12.41245 12.35164 12.28796 12.22140 12.15199 12.07973 12.00464
## [225] 11.92672
#assign fits to a vector
both_trendc <- fit_bothc
#extract y min and max for each
limits_bothc <- ggplot_build(extract_bothc)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothc <- as.data.frame(limits_bothc)
both_yminc <- limits_bothc$ymin
both_ymaxc <- limits_bothc$ymax
#reassign dataframes (just to be safe)
work_bothc <- wrfc_both
#fill in missing dates to smooth fits
work_bothc <- work_bothc %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothc <- work_bothc$date
#create a new smooth dataframe to layer
smooth_frame_bothc <- data.frame(date_vec_bothc, both_trendc, both_yminc, both_ymaxc)
#WRF C
#plot smooth frames
p_wrf_c <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothc, y = ~both_trendc,
data = smooth_frame_bothc,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc,
'</br> Median Log Copies: ', round(both_trendc, digits = 2)),
line = list(color = '#E7298A', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothc, ymin = ~both_yminc, ymax = ~both_ymaxc,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxc, digits = 2),
'</br> Min Log Copies: ', round(both_yminc, digits = 2)),
name = "",
fillcolor = '#E7298A',
line = list(color = '#E7298A')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF C") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfc_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#E7298A', size = 6, opacity = 0.65))
p_wrf_c
save(p_wrf_c, file = "./site_objects/wrf_c_year2.rda")
keeping in case
#save(wrfa_both, file = "./plotly_objs/wrfa_both.rda")
#save(wrfb_both, file = "./plotly_objs/wrfb_both.rda")
#save(wrfc_both, file = "./plotly_objs/wrfc_both.rda")
#save(date_vec_botha, file = "./plotly_objs/date_vec_botha.rda")
#save(date_vec_bothb, file = "./plotly_objs/date_vec_bothb.rda")
#save(date_vec_bothc, file = "./plotly_objs/date_vec_bothc.rda")
#save(both_ymina, file = "./plotly_objs/both_ymina.rda")
#save(both_ymaxa, file = "./plotly_objs/both_ymaxa.rda")
#save(both_yminb, file = "./plotly_objs/both_yminb.rda")
#save(both_ymaxb, file = "./plotly_objs/both_ymaxb.rda")
#save(both_yminc, file = "./plotly_objs/both_yminc.rda")
#save(both_ymaxc, file = "./plotly_objs/both_ymaxc.rda")